<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单位</title>
    <style>
        .div1 {
            width: 300px;
            height: 100px;
            background-color: blueviolet;
            color: white;
        }

        /* 一个em相当于1个font-size 
        em会根据字体大小的改变而改变
        例如:下面的size=30px width=10em 相乘就是 300px
        刚好和上面的div宽度相等
        */
        .div2 {
            font-size: 30px;
            width: 10em;
            height: 10em;
            background-color: purple;
            color: white;
        }
    </style>
</head>

<body>
    <div class="div1"> </div>
    <div class="div2">
        我是文字
    </div>
</body>

</html>